package gui.specialGUIs;

import gui.designComponents.TMTPanel;

import java.awt.BorderLayout;

import app.Controller;
import app.Model;
import definitions.Commands;

/**
 * General Overview Panel, can be used for Event and Member Overview
 * 
 * @author MK
 * 
 */
public class OverviewPanel extends TMTPanel {

	private TablePanel tablePanel;
	private TMTPanel buttonPanel;

	private Model model;
	private Controller controller;

	public OverviewPanel(Model model, Controller controller, String whatIsShown) {

		this.model = model;
		this.controller = controller;

		setLayout(new BorderLayout());

		tablePanel = new TablePanel(model, controller, whatIsShown);
		buttonPanel = new EventOverviewButtonPanel(model, controller);

		add(buttonPanel, BorderLayout.NORTH);
		add(tablePanel, BorderLayout.CENTER);
	}

	public void update(String whatIsShown) {

		remove(buttonPanel);

		tablePanel.update(whatIsShown);

		if (whatIsShown.equals(Commands.SHOW_EVENT_OVERVIEW)) {
			buttonPanel = new EventOverviewButtonPanel(model, controller);

		} else if (whatIsShown.equals(Commands.SHOW_MEMBER_OVERVIEW)) {
			buttonPanel = new MemberOverviewButtonPanel(model, controller);
		}
		add(buttonPanel, BorderLayout.NORTH);
	}

	public TablePanel getTablePanel() {
		return tablePanel;
	}
}